import 'package:flutter/material.dart';
import 'dart:io';

// 中文
import 'package:flutter_localizations/flutter_localizations.dart';

import 'routers/route.dart';

// provider全局传值，共享数据
import 'package:provider/provider.dart';
import 'provider/Cart.dart';
import 'provider/CheckOut.dart';

import 'config/Config.dart';

// 入口
void main() {
//  runApp(MyApp());
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => Cart()),
        ChangeNotifierProvider(create: (_) => CheckOut()),
      ],
      child: MyApp(),
    ),
  );
}

// 首页
class MyApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => MyAppState();
}

class MyAppState extends State {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      localizationsDelegates: [
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate
      ],
      supportedLocales: [const Locale("zh", "CH"), const Locale("en", "US")],
      debugShowCheckedModeBanner: false,
      initialRoute: '/order',
      onGenerateRoute: onGenerateRoute,
      theme: ThemeData(primaryColor: Colors.white),
    );
  }
}
